Conventionally, a linear position sensor or a rotary encoder employs a magnetic sensor with a thin ferromagnetic film magneto-resistive element made of, for example, an Fe-Ni alloy or a Co-Ni alloy. The thin ferromagnetic film magneto-resistive element (hereinafter referred to as an MR element) is generally magneto-anisotropic with respect to a particular direction beneath the film surface. It has high sensitivity to the magnetic field parallel to the film surface while having low sensitivity to the magnetic field generated along the thickness of the film surface.
With respect to this, in a magnetic sensor having an MR element, a magnet is used to generate the magnetic field in the direction of the film thickness of the MR element. Movement of the magnetic sensor along a magnetic scale, or a detected member, causes change in the magnetic flux of the component parallel to the film surface, with the amount of the change being considerable, thereby improving the detection sensitivity of the magnetic sensor. (See, Japanese Published Examined Patent Application (B2) No. 1-41226.) More particularly, as shown in FIG. 8(A), an MR element 12, affected by the bias magnetic field generated by a magnet 10 positioned at right angles to the film surface, moves along an arrow A, relative to a scale 14 having its magnetic characteristics varied by, for example, profile changes, to either the position illustrated in FIG. 8(B) or the position illustrated in FIG. 8(C), which results in the magnetic flux .phi. with gradient. Consequently, the magnetic field component parallel to the element surface acts upon the MR element, varying its electrical resistance to produce a detection signal.
However, the electrical resistance of the MR element 12 varies, as shown in FIG. 9, symmetrically with the direction of the magnetic field. Thus, as described above, the application of the bias magnetic field at right angles to the film surface of the MR element 12 causes the direction of the magnetic flux .phi. to be bent to the right in FIG. 8(B) and to the left in FIG. 8(C). No linearity can be obtained at a position along the film surface where the component of magnetic field intensity is approximately equal to zero. This results in a distortion of the output signal. With respect to this, it has been proposed to arrange the MR element in an inclined manner relative to the scale 14, and to apply a bias magnetic field (so-called transverse bias magnetic field) having a component parallel to the film surface in the MR element 12, in order to use it in linear regions a and b in FIG. 9. (See, Japanese Published Unexamined Patent Application (A) No. 60-155917.)
However, the magnetic sensor of the type described requires the arrangement of the MR element 12 in an inclined manner to the scale 14. This means that the MR element 12 is difficult to assemble, and besides, only a complicated structure can hold an inclined MR element 12. In addition, it has another disadvantage of impossibility of axial-symmetrical application of the transverse magnetic field to the sensor surface.
Additionally, a conventional magnetic sensor protects the MR element 12 by containing the MR element 12 in a sensor housing. Such conventional housing is made of a non-magnetic material to prevent, to the extent possible, the MR element 12 from being affected magnetically. It is designed to position the magnet 10 in an ideal space. Further, it has a structure such that a magnetic shield is sufficiently away from the magnet 10 for the bias magnetic field, even when the magnetic shield of the magnetic sensor is required, to avoid in every way any effect on the magnetic field generated by the magnet 10.
However, a magnetic sensor 11 used under highly loaded hostile environment in construction equipment or the like is frequently subjected to a sudden disturbance such as generation of intense magnetic field noise inherent to the engine spark. In addition, fine magnetic powders or other polarized foreign matter may often adhere on a measurement member of the scale 14 or the like. Thus the MR element 12 is affected by the magnetic circumstances despite a conventional case or a cover as the protective member being composed of non-magnetic material. There is a disadvantage that the origin has an increased drift, thereby degrading the detection precision of the magnetic sensor 11.
In addition, if a conventional magnetic sensor 11 is required to be arranged in contact with the detected member as the measurement member such as the scale 14, a sensor hole 15 is formed in a holder 13 disposed in opposition to the scale 14 and the magnetic sensor 11 is inserted into the sensor hole 15. A spring 17 is interposed between the upper end of the magnetic sensor 11 and the bottom surface of the sensor hole 15 so that the spring 17 urges the magnetic sensor 11 against the scale 14.
However, such conventional structure of mounting may cause an inclined positioning of the sensor 11 to the scale 14 due to the precision of attachment (parallelism) of the holder 13 to the scale 14 or due to inclined working of the sensor hole 15. This results in so-called one-side contact of the magnetic sensor 11. It is difficult to overcome the one-side contact problem only by means of improving workability, assembly or the dimensional tolerance. Thus a smooth relative movement between the scale 14 and the magnetic sensor 11 cannot be achieved due to the one-side contact of the magnetic sensor 11, resulting in defects of localized heating or short lifetime of the magnetic sensor due to the greater friction.
In addition, in a magnetic sensor used for a position detecting device, a linear scale or a rotary encoder to detect stroke amount of a hydraulic cylinder, the sensor is disposed in contact or close relation to the detected member. As shown in FIG. 11, the magnetic sensor 11 comprises the magnet 10 arranged above the MR element 12 through a base plate or the like (not shown) to apply the bias magnetic field to the MR element 12. Further, the magnetic sensor 11 comprises a sensor cover 16 made of a non-magnetic material like Be-P and disposed on the front surface, or the detection surface, of the MR element 12. A magnetic shield 18 surrounds the MR element 12 and the magnet 10. A rod 20 of a cylinder is made of a magnetic material, around which a peripheral groove 22 is formed in its peripheral surface at a predetermined pitch (e.g., pitch of 2 mm) and a predetermined depth (e.g., 50 .mu.m) and width. Chrome plating 24 is applied on the surface.
When the magnetic sensor 11 and the rod 20 make relative movement, a gap fluctuation or a fretting friction is caused therebetween. In addition, if the magnetic sensor 11 is used in contact with the rod 20, the sensor characteristic is varied due to heating of the magnetic sensor 11. Thus, in order to prevent the magnetic sensor 11 from being worn or broken as a result of direct contact with the detected member, or to keep a constant distance between the magnetic sensor 11 and the detected member, a protective member is often attached to a tip portion of the magnetic sensor 11.
More particularly, as shown in FIG. 12, a conventional sensor comprises a protective member 19a in the form of a cap covering the whole tip portion of the magnetic sensor 11 to engage the cap-like protective member 19a with the magnetic sensor 11. Alternatively, a protective member 19b is formed like a hollow cylinder as shown in FIG. 13, and the hollow cylindrical protective member 19b is fitted to the tip portion of the magnetic sensor 11. Otherwise, the magnetic sensor 11 is contained in a protective case 19c as shown in FIG. 14.
However, when the cap-like protective member 19a or hollow cylindrical protective member 19b is fitted to the magnetic sensor 11, it tends to slip off due to vibration or the like. If the magnetic sensor 11 is adhered to the protective member 19a, 19b only to avoid the slip-off, it becomes impossible to replace the protective member 19a, 19b when worn or damaged. This results in a shorter lifetime of the magnetic sensor 11. When the whole magnetic sensor 11 is contained in the protective case 19c as shown in FIG. 14, there are defects of increased cost and complicated structure because a supporting mechanism should be disposed for the magnetic sensor 11 within the protective case 19c.